﻿#region Using directives

using System;
using System.Collections.Generic;
using System.Text;

using Weazel.Math;

using Microsoft.VisualStudio.TestTools.UnitTesting;

#endregion

namespace Weazel.Math.Test
{
  [TestClass]
  public class TestToString
  {
    [TestMethod]
    public void TestToDecimalString_1()
    {
      Integer a = new Integer(8, 0x100, false);
      Assert.AreEqual("0", a.ToDecimalString());
    }

    [TestMethod]
    public void TestToDecimalString_2()
    {
      Integer a = new Integer(8, 0xFF, false);
      Integer b = new Integer(8, 1, false);
      Integer r = new Integer(8, false);

      Integer.Add(ref r, a, b);

      Assert.AreEqual("0", r.ToDecimalString());
    }

    [TestMethod]
    public void TestToHexaDecimalString_1()
    {
      Integer a = new Integer("1");
      Assert.AreEqual(false, a.Signed);     
      Assert.AreEqual("1", a.ToHexadecimalString());
    }

    [TestMethod]
    public void TestToStringDecimalBase()
    {
      Integer a = new Integer("1");
      Assert.AreEqual("1", a.ToString(10));
    }

    [TestMethod]
    public void TestToStringBinaryBase()
    {
      Integer a = new Integer("1");
      Assert.AreEqual("01", a.ToString(2));
    }

    [TestMethod]
    public void TestToStringHexadecimalBase()
    {
      Integer a = new Integer("15");
      Assert.AreEqual("f", a.ToString(16));
    }

    [TestMethod]
    public void TestToStringInvalidRadixBase()
    {
      Integer a = new Integer("15");
     
      try
      {
        a.ToString(78);
        Assert.Fail();
      }
      catch (NotSupportedException)
      {
        return;
      }

      Assert.Fail();
    }

    [TestMethod]
    public void TestToStringNoArguments()
    {
      Integer a = new Integer("15");

      Assert.AreEqual("15", a.ToString());
    }
  }
}
